#include "choosewindow.h"
#include "ui_choosewindow.h"
#include "mainscene.h"
#include<QPainter>
#include"counter.h"
#include<QMessageBox>
ChooseWindow::ChooseWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ChooseWindow)
{
    ui->setupUi(this);
    this->Scene = new ShootScene;
    this->ui->graphicsView->setScene(Scene);
    //三个按钮
    connect(this->ui->StartGame,SIGNAL(clicked()),this->Scene,SLOT(GameStart()));
    connect(this->ui->EndGame,SIGNAL(clicked()),this->Scene,SLOT(GameEnd()));
    connect(this->ui->CleanScore,&QPushButton::clicked,this->ui->lcdNumber,[=](){
        this->score = 0;
        this->ui->lcdNumber->display(this->score);
    });
    //计分系统
    this->score = 0;
    counter *count = counter::getExample();
    connect(count,SIGNAL(KilledKND()),this,SLOT(UpdateScore()));
    //关于
    connect(this->ui->actionAbout_Choose,&QAction::triggered,[=](){
        QMessageBox::information(this,"关于","Designed by XeonGT\n版本：0.1.0\n日期：2022.4.30");
    });
}
ChooseWindow::~ChooseWindow()
{
    delete ui;
}
void ChooseWindow::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/HappySwing.jpeg");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
void ChooseWindow::UpdateScore(){
    this->score += 10;
    this->ui->lcdNumber->display(this->score);
}
